/* -+- file  ./kf2/GUI/SubscribeDialog.cs -+- */
/*
 * kf2 jabber client
 * ~~~~~~~~~~~~~~~~~
 *
 * Copyright (C) 2006-2007 Przemysław Sitek
 * 				<przemyslaw.sitek at wp.pl> 
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License as
 * published by the Free Software Foundation; either version 2 of the
 * License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 * Boston, MA 02111-1307, USA.
 */

using System;
using Habazie.kf2.Core;
using Habazie.kf2.Net;

namespace Habazie.kf2.GUI
{
	
	
	public class SubscribeDialog : Gtk.Dialog
	{
		private Account m_Account;
		private jabber.protocol.client.Presence m_Presence;
		protected Gtk.Label m_Jid;
		
		public SubscribeDialog(Account acc, jabber.protocol.client.Presence presence) : base ()
		{
			Stetic.Gui.Build(this, typeof(Habazie.kf2.GUI.SubscribeDialog));

			m_Account = acc;
			m_Presence = presence;
			m_Jid.Markup = String.Format ("<i>{0}</i>", presence.From);
		}

		protected virtual void OnYesClicked(object sender, System.EventArgs e)
		{
			Hide ();
			jabber.protocol.client.Presence p = new jabber.protocol.client.Presence (m_Account.Document);
			p.To = m_Presence.From;
			p.Type = jabber.protocol.client.PresenceType.subscribed;
			m_Account.Write (p);
			Destroy ();
		}

		protected virtual void OnNoClicked(object sender, System.EventArgs e)
		{
			Hide ();
			jabber.protocol.client.Presence p = new jabber.protocol.client.Presence (m_Account.Document);
			p.To = m_Presence.From;
			p.Type = jabber.protocol.client.PresenceType.unsubscribed;
			m_Account.Write (p);
			Destroy ();
		}

		protected virtual void OnCloseClicked(object sender, System.EventArgs e)
		{
			Hide ();
			Destroy ();
		}
	}
}
